function demoDrawableTextures(delay)
% Demonstrate drawing arbitrary textures, allow visual inspection.

if nargin < 1
    delay = 2;
end

% access the manager that deals with drawing
dotsTheDrawablesManager.reset();
dm = dotsTheDrawablesManager.theObject;

% create a texture-drawing object
tx = dm.newObject('dotsDrawableTextures');

% configure the texture object to draw a checkerboard texture with some
% colored checkers.
% The "checkerTextureMaker" function is included along with this
% demo script.  It knows how to make a checkerboard texture with
% OpenGL.  It expectes to receive the texture object and a color
% parameter.
red = [192 16 16];
tx.textureMakerFevalable = {@checkerTextureMaker, red};

% checkers should have abrupt edges, not smooth blending
tx.smooth = false;

% create a target dot to display near or behind the texture
dot = dm.newObject('dotsDrawableTargets');
blue = [16 0 128];
dot.size = 1;
dot.color = blue;

% add the texture and dot objects to a group to draw them together
%   the last parameter allows us to sort the group by drawing order
group = 'demo';
dm.addObjectToGroup(dot, group, 1);
dm.addObjectToGroup(tx, group, 2);
dm.activateGroup(group);

% get ready to draw in an OpenGL drawing window
dm.openScreenWindow;

% draw the checkered texture at a small size
%   it will occlude the blue dot
tx.width = 1;
tx.height = 1;
dm.mayDrawNextFrame;
pause(delay);

% draw the checkered texture at a larger size
%   it will still occlude the blue dot
tx.width = 10;
tx.height = 5;
dm.mayDrawNextFrame;
pause(delay);

% draw the checkered texture at a larger size, and other changes
%   it will rotate and move to reveal the blue dot behind it!
tx.x = -5;
tx.rotation = 45;
tx.smooth = true;
dm.mayDrawNextFrame;
pause(delay);

% close the OpenGL drawing window
dm.closeScreenWindow;